<?xml version="1.0" encoding="euc-kr" ?>
<%@ page language="java" contentType="text/xml; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="kr.co.chat.util.ChatDB" %>
<%@ page import="kr.co.chat.util.ChatMessage" %>
<%@ page import="java.util.ArrayList" %>
<%
int newLastMsgID = 0;
int lastMsgID = Integer.parseInt(request.getParameter("lastMsgID"));

ArrayList loadMsgList = ChatDB.getInstance().getMessage(lastMsgID);
%>
<RESULT>
<%
if(loadMsgList.size() > 0)
{
	for(int i = 0; i < loadMsgList.size(); i++)
	{
		ChatMessage chatMsg = (ChatMessage)loadMsgList.get(i);
		newLastMsgID = chatMsg.getMessageID();
	%>
		<MESSAGES>
	<%
		if(chatMsg.getNickName().equals(""))
		{
	%>
			<CODE>0</CODE>
			<MSGID><%= chatMsg.getMessageID() %></MSGID>
			<NICKNAME>0</NICKNAME>
			<MESSAGE><%= chatMsg.getMessage().replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;") %></MESSAGE>
	<%
		}
		else
		{
	%>
			<CODE>1</CODE>
			<MSGID><%= chatMsg.getMessageID() %></MSGID>
			<NICKNAME><%= chatMsg.getNickName() %></NICKNAME>
			<MESSAGE><%= chatMsg.getMessage().replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;") %></MESSAGE>
	<%
		}
	%>
		</MESSAGES>
	<%
	}
	%>
	<LASTMSGID><%= newLastMsgID %></LASTMSGID>
<%
}
loadMsgList.clear();
loadMsgList = null;
%>
</RESULT>